<template>
	<view v-if="list" class="content poRel">
		<view class="wid100 borRad10" style="height: 520rpx;">
			<image :src="url+list.cover_img" class="wh100"></image>
		</view>
		<view class="wid90 mar mar-top40 bacFFF borRad20" style="padding: 20rpx;box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(199,199,199,0.16);">
			<view class="foSi30 fowe600 wid90 mar">{{list.title}}</view>
			<view class="mar-top20 dis disAl disJuB wid90 mar">
				<view class="fowe600 foSi30" style="color: #FF0000;">{{list.price}}积分</view>
				<view class="foSi20" style="color: #686868;">已兑换{{list.sort}}件</view>
			</view>
		</view>
		<view class="wid90 mar mar-top40 bacFFF borRad20" style="padding: 20rpx;box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(199,199,199,0.16);">
			<view class="foSi35 fowe600 mar-bott30">兑换详情</view>
			<rich-text :nodes="list.content"></rich-text>
		</view>
		<view style="height: 120rpx;" :style="'padding-bottom: '+(bottomHight - 20)+'px;'"></view>
		<view class="wid100 bacFFF poFix" style="bottom: 0;">
			<view class="dis disAl" style="height: 120rpx;">
				<view class="hei80 wid90 mar borRad10 dis disAl disJuC foSi30 coFFF" 
					style="background-color: #035DFF;" @click.stop="tiaozhuan('/pages/user/exchange?id='+list.id)">消耗{{list.price}}积分兑换</view>
			</view>
			<view v-if="bottomHight != 0" :style="'height: '+(bottomHight - 20)+'px;'"></view>
		</view>
	</view>
</template>

<script>
	import { Goods } from '../../model/integralgoods-model';
	var Goods2 = new Goods()
	import { Config } from '../../utils/config.js';
	export default {
		data() {
			return {
				url: Config.restUrl,
				bottomHight: 0,
				id: 0,
				list: null
			}
		},
		onLoad(option) {
			let app = uni.getSystemInfoSync();
			this.bottomHight = app.safeAreaInsets.bottom //屏幕底部安全距离
			this.id = option.id
			this.getList()
		},
		methods: {
			getList() {
				var that = this
				let params = {
					id: that.id
				}
				Goods2.goddsDetails((data) => {
					console.log(data)
					if (data.code === 0) {
						that.list = data.data
						that.list.content = that.list.content.replace(/<img/gi, "<img class='richImg'");
					} else {
						uni.showToast({
							title: data.msg,
							icon: 'none',
							duration: 2000
						})
					}
				}, params)
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background-color: #F8F9FD;
		height: 100vh;
	}
	.richImg {
	    width: 100% !important;
	    height: auto !important;
	}
</style>
